{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "8ZelAXba3D05"
   },
   "source": [
    "![JohnSnowLabs](https://nlp.johnsnowlabs.com/assets/images/logo.png)\n",
    "\n",
    "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/JohnSnowLabs/nlu/blob/master/examples/colab/healthcare/entity_resolution/entity_resolvers_overview.ipynb)\n",
    "\n",
    "\n",
    "\n",
    "# Entity Resolution\n",
    "**Named entities** are sub-strings in a text that can be classified into catogires. For example, in the String   \n",
    "`\"Tesla is a great stock to invest  in \"` , the sub-string `\"Tesla\"` is a named entity, it can be classified with the label `company` by an ML algorithm.  \n",
    "**Named entities** can easily be extracted by the various pre-trained Deep Learning based NER algorithms provided by NLU.\n",
    "\n",
    "\n",
    "\n",
    "After extracting **named entities** an **entity resolution algorithm** can be applied to the extracted named entities. The resolution algorithm classifies each extracted entitiy into a class, which reduces dimensionality of the data and has many useful applications.\n",
    "For example :\n",
    "- \"**Tesla** is a great stock to invest in \"\n",
    "- \"**TSLA**  is a great stock to invest  in \"\n",
    "- \"**Tesla, Inc** is a great company to invest in\"    \n",
    "\n",
    "The sub-strings `Tesla` , `TSLA` and `Tesla, Inc` are all named entities, that are classified with the labeld `company` by the NER algorithm. It tells us, all these 3 sub-strings are of type `company`, but we cannot yet infer that these 3 strings are actually referring to literally the same company.    \n",
    "\n",
    "This exact problem is solved by the resolver algorithms, it would resolve all these 3 entities to a common name, like a company ID. This maps every reference of Tesla, regardless of how the string is represented, to the same ID.\n",
    "\n",
    "This example can analogusly be expanded to healthcare any any other text problems. In medical documents, the same disease can be referenced in many different ways.\n",
    "\n",
    "With NLU Healthcare you can leverage state of the art pre-trained NER models to extract **Medical Named Entities** (Diseases, Treatments, Posology, etc..) and **resolve these** to common **healthcare disease codes**.\n",
    "\n",
    "\n",
    "These algorithms are based provided by **Spark NLP for Healthcare's**  [SentenceEntitiyResolver](https://nlp.johnsnowlabs.com/docs/en/licensed_annotators#sentenceentityresolver) and [ChunkEntityResolvers](https://nlp.johnsnowlabs.com/docs/en/licensed_annotators#chunkentityresolver)\n",
    "\n",
    "\n",
    "## Avaiable models\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "All the models avaiable are :\n",
    "\n",
    "\n",
    "| Language | nlp.load() reference                                         | Spark NLP Model reference          |\n",
    "| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ |\n",
    "| English  | embed_sentence.biobert.mli | sbiobert_base_cased_mli          |\n",
    "| English  | resolve | sbiobertresolve_cpt          |\n",
    "| English  | resolve.cpt | sbiobertresolve_cpt          |\n",
    "| English  | resolve.cpt.augmented | sbiobertresolve_cpt_augmented          |\n",
    "| English  | resolve.cpt.procedures_augmented | sbiobertresolve_cpt_procedures_augmented          |\n",
    "| English  | resolve.hcc.augmented | sbiobertresolve_hcc_augmented          |\n",
    "| English  | [resolve.icd10cm](https://nlp.johnsnowlabs.com/2020/11/27/sbiobertresolve_icd10cm_en.html) | [sbiobertresolve_icd10cm](https://nlp.johnsnowlabs.com/2020/11/27/sbiobertresolve_icd10cm_en.html)                   |\n",
    "| English  | [resolve.icd10cm.augmented](https://nlp.johnsnowlabs.com/2020/12/13/sbiobertresolve_icd10cm_augmented_en.html) | [sbiobertresolve_icd10cm_augmented](https://nlp.johnsnowlabs.com/2020/12/13/sbiobertresolve_icd10cm_augmented_en.html)                   |\n",
    "| English  | [resolve.icd10cm.augmented_billable](https://nlp.johnsnowlabs.com/2021/02/06/sbiobertresolve_icd10cm_augmented_billable_hcc_en.html) | [sbiobertresolve_icd10cm_augmented_billable_hcc](https://nlp.johnsnowlabs.com/2021/02/06/sbiobertresolve_icd10cm_augmented_billable_hcc_en.html)                   |\n",
    "| English  | [resolve.icd10pcs](https://nlp.johnsnowlabs.com/2020/11/27/sbiobertresolve_icd10pcs_en.html) | [sbiobertresolve_icd10pcs](https://nlp.johnsnowlabs.com/2020/11/27/sbiobertresolve_icd10pcs_en.html)                   |\n",
    "| English  | [resolve.icdo](https://nlp.johnsnowlabs.com/2020/11/27/sbiobertresolve_icdo_en.html) | [sbiobertresolve_icdo](https://nlp.johnsnowlabs.com/2020/11/27/sbiobertresolve_icdo_en.html)                   |\n",
    "| English  | [resolve.rxcui](https://nlp.johnsnowlabs.com/2020/12/11/sbiobertresolve_rxcui_en.html) | [sbiobertresolve_rxcui](https://nlp.johnsnowlabs.com/2020/12/11/sbiobertresolve_rxcui_en.html)                   |\n",
    "| English  | [resolve.rxnorm](https://nlp.johnsnowlabs.com/2020/11/27/sbiobertresolve_rxnorm_en.html) | [sbiobertresolve_rxnorm](https://nlp.johnsnowlabs.com/2020/11/27/sbiobertresolve_rxnorm_en.html)                   |\n",
    "| English  | [resolve.snomed](https://nlp.johnsnowlabs.com/2020/11/27/sbiobertresolve_snomed_auxConcepts_en.html) | [sbiobertresolve_snomed_auxConcepts](https://nlp.johnsnowlabs.com/2020/11/27/sbiobertresolve_snomed_auxConcepts_en.html)                   |\n",
    "| English  | [resolve.snomed.aux_concepts](https://nlp.johnsnowlabs.com/2020/11/27/sbiobertresolve_snomed_auxConcepts_en.html) | [sbiobertresolve_snomed_auxConcepts](https://nlp.johnsnowlabs.com/2020/11/27/sbiobertresolve_snomed_auxConcepts_en.html)                   |\n",
    "| English  | [resolve.snomed.aux_concepts_int](https://nlp.johnsnowlabs.com/2020/11/27/sbiobertresolve_snomed_auxConcepts_int_en.html) | [sbiobertresolve_snomed_auxConcepts_int](https://nlp.johnsnowlabs.com/2020/11/27/sbiobertresolve_snomed_auxConcepts_int_en.html)                   |\n",
    "| English  | [resolve.snomed.findings](https://nlp.johnsnowlabs.com/2020/11/27/sbiobertresolve_snomed_findings_en.html) | [sbiobertresolve_snomed_findings](https://nlp.johnsnowlabs.com/2020/11/27/sbiobertresolve_snomed_findings_en.html)                   |\n",
    "| English  | [resolve.snomed.findings_int](https://nlp.johnsnowlabs.com/2020/11/27/sbiobertresolve_snomed_findings_int_en.html) | [sbiobertresolve_snomed_findings_int](https://nlp.johnsnowlabs.com/2020/11/27/sbiobertresolve_snomed_findings_int_en.html)                   |\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "2ng0xw1YE3LO"
   },
   "outputs": [],
   "source": [
    "from johnsnowlabs import nlp\n",
    "\n",
    "# After uploading your license run this to install all licensed Python Wheels and pre-download Jars the Spark Session JVM\n",
    "nlp.install()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "rSUTBWKi6Hb-"
   },
   "source": [
    "#### [Sentence Entity Resolver for ICD10-CM (sbiobert_base_cased_mli embeddings)](https://nlp.johnsnowlabs.com/2020/11/27/sbiobertresolve_icd10cm_en.html)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 535
    },
    "id": "emvKNnXE6HBv",
    "outputId": "ec1fc7e5-ec78-429c-efd8-22948c58be73"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warning::Spark Session already created, some configs may not take.\n",
      "Warning::Spark Session already created, some configs may not take.\n",
      "ner_wikiner_glove_840B_300 download started this may take some time.\n",
      "Approximate size to download 14.8 MB\n",
      "[OK!]\n",
      "sbiobertresolve_icd10cm download started this may take some time.\n",
      "[OK!]\n",
      "setInputCols in ENTITY_05f4bc95f0c5 expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: ['sentence_embeddings']\n",
      "sbiobert_base_cased_mli download started this may take some time.\n",
      "Approximate size to download 384.3 MB\n",
      "[OK!]\n",
      "glove_840B_300 download started this may take some time.\n",
      "Approximate size to download 2.3 GB\n",
      "[OK!]\n",
      "setInputCols in ENTITY_05f4bc95f0c5 expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: ['sentence_embeddings']\n",
      "setInputCols in ENTITY_05f4bc95f0c5 expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: ['sentence_embeddings']\n",
      "setInputCols in ENTITY_05f4bc95f0c5 expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: ['sentence_embeddings']\n",
      "sentence_detector_dl download started this may take some time.\n",
      "Approximate size to download 354.6 KB\n",
      "[OK!]\n",
      "Warning::Spark Session already created, some configs may not take.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "  <div id=\"df-83deb877-17ae-4d3b-b7fc-92c57e1c453c\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>entities_wikiner_glove_840B_300</th>\n",
       "      <th>entities_wikiner_glove_840B_300_class</th>\n",
       "      <th>entities_wikiner_glove_840B_300_confidence</th>\n",
       "      <th>entities_wikiner_glove_840B_300_origin_chunk</th>\n",
       "      <th>entities_wikiner_glove_840B_300_origin_sentence</th>\n",
       "      <th>resolution_icd10cm_code</th>\n",
       "      <th>resolution_icd10cm_confidence</th>\n",
       "      <th>resolution_icd10cm_distance</th>\n",
       "      <th>resolution_icd10cm_k_codes</th>\n",
       "      <th>resolution_icd10cm_k_confidences</th>\n",
       "      <th>resolution_icd10cm_k_cos_distances</th>\n",
       "      <th>resolution_icd10cm_k_distances</th>\n",
       "      <th>resolution_icd10cm_k_resolution</th>\n",
       "      <th>resolution_icd10cm_origin_sentence</th>\n",
       "      <th>resolution_icd10cm_resolved_text</th>\n",
       "      <th>resolution_icd10cm_target_text</th>\n",
       "      <th>resolution_icd10cm_token</th>\n",
       "      <th>sentence</th>\n",
       "      <th>sentence_embedding_biobert</th>\n",
       "      <th>word_embedding_glove</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>[Braintree, non-ST, Guaiac, St, Margaret's Cen...</td>\n",
       "      <td>[LOC, MISC, MISC, LOC, ORG, ORG, ORG]</td>\n",
       "      <td>[0.8775, 0.873, 0.3519, 0.5045, 0.43828332, 0....</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>[L946, I781, B483, R061, O3402, A57, A57]</td>\n",
       "      <td>[0.3423, 0.3456, 0.3525, 0.3601, 0.3349, 0.334...</td>\n",
       "      <td>[0.5333, 0.3553, 0.3299, 0.3006, 0.4539, 0.484...</td>\n",
       "      <td>[[L946, L0213, M5145], [I781, Y66, S1191XS], [...</td>\n",
       "      <td>[[0.3423, 0.3289, 0.3288], [0.3456, 0.3329, 0....</td>\n",
       "      <td>[[0.2845, 0.3285, 0.3288], [0.1263, 0.1542, 0....</td>\n",
       "      <td>[[0.5333, 0.5731, 0.5734], [0.3553, 0.3927, 0....</td>\n",
       "      <td>[[Ainhum, Carbuncle of neck, Schmorl's nodes, ...</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>[Ainhum, Nevus, non-neoplastic, Geotrichosis, ...</td>\n",
       "      <td>[Braintree, non-ST, Guaiac, St, Margaret's Cen...</td>\n",
       "      <td>[Braintree, non-ST, Guaiac, St, Margaret's Cen...</td>\n",
       "      <td>This is an 82 - year-old male with a history o...</td>\n",
       "      <td>[[0.41123586893081665, 0.3981207609176636, -0....</td>\n",
       "      <td>[[-0.27410000562667847, 0.22980999946594238, 0...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-83deb877-17ae-4d3b-b7fc-92c57e1c453c')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-83deb877-17ae-4d3b-b7fc-92c57e1c453c button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-83deb877-17ae-4d3b-b7fc-92c57e1c453c');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "                     entities_wikiner_glove_840B_300  \\\n",
       "0  [Braintree, non-ST, Guaiac, St, Margaret's Cen...   \n",
       "\n",
       "   entities_wikiner_glove_840B_300_class  \\\n",
       "0  [LOC, MISC, MISC, LOC, ORG, ORG, ORG]   \n",
       "\n",
       "          entities_wikiner_glove_840B_300_confidence  \\\n",
       "0  [0.8775, 0.873, 0.3519, 0.5045, 0.43828332, 0....   \n",
       "\n",
       "  entities_wikiner_glove_840B_300_origin_chunk  \\\n",
       "0                        [0, 1, 2, 3, 4, 5, 6]   \n",
       "\n",
       "  entities_wikiner_glove_840B_300_origin_sentence  \\\n",
       "0                           [0, 0, 0, 0, 0, 0, 0]   \n",
       "\n",
       "                     resolution_icd10cm_code  \\\n",
       "0  [L946, I781, B483, R061, O3402, A57, A57]   \n",
       "\n",
       "                       resolution_icd10cm_confidence  \\\n",
       "0  [0.3423, 0.3456, 0.3525, 0.3601, 0.3349, 0.334...   \n",
       "\n",
       "                         resolution_icd10cm_distance  \\\n",
       "0  [0.5333, 0.3553, 0.3299, 0.3006, 0.4539, 0.484...   \n",
       "\n",
       "                          resolution_icd10cm_k_codes  \\\n",
       "0  [[L946, L0213, M5145], [I781, Y66, S1191XS], [...   \n",
       "\n",
       "                    resolution_icd10cm_k_confidences  \\\n",
       "0  [[0.3423, 0.3289, 0.3288], [0.3456, 0.3329, 0....   \n",
       "\n",
       "                  resolution_icd10cm_k_cos_distances  \\\n",
       "0  [[0.2845, 0.3285, 0.3288], [0.1263, 0.1542, 0....   \n",
       "\n",
       "                      resolution_icd10cm_k_distances  \\\n",
       "0  [[0.5333, 0.5731, 0.5734], [0.3553, 0.3927, 0....   \n",
       "\n",
       "                     resolution_icd10cm_k_resolution  \\\n",
       "0  [[Ainhum, Carbuncle of neck, Schmorl's nodes, ...   \n",
       "\n",
       "  resolution_icd10cm_origin_sentence  \\\n",
       "0              [0, 0, 0, 0, 0, 0, 0]   \n",
       "\n",
       "                    resolution_icd10cm_resolved_text  \\\n",
       "0  [Ainhum, Nevus, non-neoplastic, Geotrichosis, ...   \n",
       "\n",
       "                      resolution_icd10cm_target_text  \\\n",
       "0  [Braintree, non-ST, Guaiac, St, Margaret's Cen...   \n",
       "\n",
       "                            resolution_icd10cm_token  \\\n",
       "0  [Braintree, non-ST, Guaiac, St, Margaret's Cen...   \n",
       "\n",
       "                                            sentence  \\\n",
       "0  This is an 82 - year-old male with a history o...   \n",
       "\n",
       "                          sentence_embedding_biobert  \\\n",
       "0  [[0.41123586893081665, 0.3981207609176636, -0....   \n",
       "\n",
       "                                word_embedding_glove  \n",
       "0  [[-0.27410000562667847, 0.22980999946594238, 0...  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nlp.load(\"med_ner.jsl.wip.clinical en.resolve.icd10cm\").predict(\"\"\"This is an 82 - year-old male with a history of prior tobacco use , hypertension , chronic renal insufficiency , COPD ,\n",
    "gastritis , and TIA who initially presented to Braintree with a non-ST elevation MI and Guaiac positive stools , transferred to St . Margaret\\'s Center for Women & Infants for cardiac\n",
    "catheterization with PTCA to mid LAD lesion complicated by hypotension and bradycardia requiring Atropine , IV fluids and transient dopamine possibly secondary to vagal reaction ,\n",
    "subsequently transferred to CCU for close monitoring , hemodynamically stable at the time of admission to the CCU .\"\"\",output_level =  \"sentence\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "GlKDEOCrG13g"
   },
   "source": [
    "#### [Sentence Entity Resolver for ICD10-PCS (sbiobert_base_cased_mli embeddings)](https://nlp.johnsnowlabs.com/2020/11/27/sbiobertresolve_icd10pcs_en.html)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 535
    },
    "id": "AQjiCfFQG13h",
    "outputId": "4add16c4-17e2-4283-8e5a-561e62e2d51d"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warning::Spark Session already created, some configs may not take.\n",
      "Warning::Spark Session already created, some configs may not take.\n",
      "ner_wikiner_glove_840B_300 download started this may take some time.\n",
      "Approximate size to download 14.8 MB\n",
      "[OK!]\n",
      "sbiobertresolve_icd10pcs download started this may take some time.\n",
      "[OK!]\n",
      "setInputCols in ENTITY_7090bfd98dcf expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: ['sentence_embeddings']\n",
      "sbiobert_base_cased_mli download started this may take some time.\n",
      "Approximate size to download 384.3 MB\n",
      "[OK!]\n",
      "glove_840B_300 download started this may take some time.\n",
      "Approximate size to download 2.3 GB\n",
      "[OK!]\n",
      "setInputCols in ENTITY_7090bfd98dcf expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: ['sentence_embeddings']\n",
      "setInputCols in ENTITY_7090bfd98dcf expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: ['sentence_embeddings']\n",
      "setInputCols in ENTITY_7090bfd98dcf expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: ['sentence_embeddings']\n",
      "sentence_detector_dl download started this may take some time.\n",
      "Approximate size to download 354.6 KB\n",
      "[OK!]\n",
      "Warning::Spark Session already created, some configs may not take.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "  <div id=\"df-a03e8f5f-4de7-485e-b06d-2807fc14d1cb\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>entities_wikiner_glove_840B_300</th>\n",
       "      <th>entities_wikiner_glove_840B_300_class</th>\n",
       "      <th>entities_wikiner_glove_840B_300_confidence</th>\n",
       "      <th>entities_wikiner_glove_840B_300_origin_chunk</th>\n",
       "      <th>entities_wikiner_glove_840B_300_origin_sentence</th>\n",
       "      <th>resolution_icd10pcs_code</th>\n",
       "      <th>resolution_icd10pcs_confidence</th>\n",
       "      <th>resolution_icd10pcs_distance</th>\n",
       "      <th>resolution_icd10pcs_k_codes</th>\n",
       "      <th>resolution_icd10pcs_k_confidences</th>\n",
       "      <th>resolution_icd10pcs_k_cos_distances</th>\n",
       "      <th>resolution_icd10pcs_k_distances</th>\n",
       "      <th>resolution_icd10pcs_k_resolution</th>\n",
       "      <th>resolution_icd10pcs_origin_sentence</th>\n",
       "      <th>resolution_icd10pcs_resolved_text</th>\n",
       "      <th>resolution_icd10pcs_target_text</th>\n",
       "      <th>resolution_icd10pcs_token</th>\n",
       "      <th>sentence</th>\n",
       "      <th>sentence_embedding_biobert</th>\n",
       "      <th>word_embedding_glove</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>[Braintree, non-ST, Guaiac, St, Margaret's Cen...</td>\n",
       "      <td>[LOC, MISC, MISC, LOC, ORG, ORG, ORG]</td>\n",
       "      <td>[0.8775, 0.873, 0.3519, 0.5045, 0.43828332, 0....</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>[B040ZZZ, F00Z7ZZ, F00ZDZZ, F01ZCZZ, BY4DZZZ, ...</td>\n",
       "      <td>[0.3347, 0.3430, 0.3399, 0.3471, 0.3350, 0.338...</td>\n",
       "      <td>[0.5942, 0.4194, 0.4798, 0.4559, 0.5078, 0.524...</td>\n",
       "      <td>[[B040ZZZ, 2W65XZZ, F14Z3ZZ], [F00Z7ZZ, 5A1905...</td>\n",
       "      <td>[[0.3347, 0.3336, 0.3317], [0.3430, 0.3306, 0....</td>\n",
       "      <td>[[0.3531, 0.3571, 0.3639], [0.1759, 0.2082, 0....</td>\n",
       "      <td>[[0.5942, 0.5976, 0.6032], [0.4194, 0.4563, 0....</td>\n",
       "      <td>[[Ultrasonography of Brain, Traction of Back, ...</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>[Ultrasonography of Brain, Nonspoken Language ...</td>\n",
       "      <td>[Braintree, non-ST, Guaiac, St, Margaret's Cen...</td>\n",
       "      <td>[Braintree, non-ST, Guaiac, St, Margaret's Cen...</td>\n",
       "      <td>This is an 82 - year-old male with a history o...</td>\n",
       "      <td>[[0.41123586893081665, 0.3981207609176636, -0....</td>\n",
       "      <td>[[-0.27410000562667847, 0.22980999946594238, 0...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-a03e8f5f-4de7-485e-b06d-2807fc14d1cb')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-a03e8f5f-4de7-485e-b06d-2807fc14d1cb button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-a03e8f5f-4de7-485e-b06d-2807fc14d1cb');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "                     entities_wikiner_glove_840B_300  \\\n",
       "0  [Braintree, non-ST, Guaiac, St, Margaret's Cen...   \n",
       "\n",
       "   entities_wikiner_glove_840B_300_class  \\\n",
       "0  [LOC, MISC, MISC, LOC, ORG, ORG, ORG]   \n",
       "\n",
       "          entities_wikiner_glove_840B_300_confidence  \\\n",
       "0  [0.8775, 0.873, 0.3519, 0.5045, 0.43828332, 0....   \n",
       "\n",
       "  entities_wikiner_glove_840B_300_origin_chunk  \\\n",
       "0                        [0, 1, 2, 3, 4, 5, 6]   \n",
       "\n",
       "  entities_wikiner_glove_840B_300_origin_sentence  \\\n",
       "0                           [0, 0, 0, 0, 0, 0, 0]   \n",
       "\n",
       "                            resolution_icd10pcs_code  \\\n",
       "0  [B040ZZZ, F00Z7ZZ, F00ZDZZ, F01ZCZZ, BY4DZZZ, ...   \n",
       "\n",
       "                      resolution_icd10pcs_confidence  \\\n",
       "0  [0.3347, 0.3430, 0.3399, 0.3471, 0.3350, 0.338...   \n",
       "\n",
       "                        resolution_icd10pcs_distance  \\\n",
       "0  [0.5942, 0.4194, 0.4798, 0.4559, 0.5078, 0.524...   \n",
       "\n",
       "                         resolution_icd10pcs_k_codes  \\\n",
       "0  [[B040ZZZ, 2W65XZZ, F14Z3ZZ], [F00Z7ZZ, 5A1905...   \n",
       "\n",
       "                   resolution_icd10pcs_k_confidences  \\\n",
       "0  [[0.3347, 0.3336, 0.3317], [0.3430, 0.3306, 0....   \n",
       "\n",
       "                 resolution_icd10pcs_k_cos_distances  \\\n",
       "0  [[0.3531, 0.3571, 0.3639], [0.1759, 0.2082, 0....   \n",
       "\n",
       "                     resolution_icd10pcs_k_distances  \\\n",
       "0  [[0.5942, 0.5976, 0.6032], [0.4194, 0.4563, 0....   \n",
       "\n",
       "                    resolution_icd10pcs_k_resolution  \\\n",
       "0  [[Ultrasonography of Brain, Traction of Back, ...   \n",
       "\n",
       "  resolution_icd10pcs_origin_sentence  \\\n",
       "0               [0, 0, 0, 0, 0, 0, 0]   \n",
       "\n",
       "                   resolution_icd10pcs_resolved_text  \\\n",
       "0  [Ultrasonography of Brain, Nonspoken Language ...   \n",
       "\n",
       "                     resolution_icd10pcs_target_text  \\\n",
       "0  [Braintree, non-ST, Guaiac, St, Margaret's Cen...   \n",
       "\n",
       "                           resolution_icd10pcs_token  \\\n",
       "0  [Braintree, non-ST, Guaiac, St, Margaret's Cen...   \n",
       "\n",
       "                                            sentence  \\\n",
       "0  This is an 82 - year-old male with a history o...   \n",
       "\n",
       "                          sentence_embedding_biobert  \\\n",
       "0  [[0.41123586893081665, 0.3981207609176636, -0....   \n",
       "\n",
       "                                word_embedding_glove  \n",
       "0  [[-0.27410000562667847, 0.22980999946594238, 0...  "
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nlp.load(\"med_ner.jsl.wip.clinical en.resolve.icd10pcs\").predict(\"\"\"This is an 82 - year-old male with a history of prior tobacco use , hypertension , chronic renal insufficiency , COPD ,\n",
    "gastritis , and TIA who initially presented to Braintree with a non-ST elevation MI and Guaiac positive stools , transferred to St . Margaret\\'s Center for Women & Infants for cardiac\n",
    "catheterization with PTCA to mid LAD lesion complicated by hypotension and bradycardia requiring Atropine , IV fluids and transient dopamine possibly secondary to vagal reaction ,\n",
    "subsequently transferred to CCU for close monitoring , hemodynamically stable at the time of admission to the CCU .\"\"\",output_level =  \"sentence\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "lMep62x_G2AS"
   },
   "source": [
    "#### [Sentence Entity Resolver for RxCUI (sbiobert_base_cased_mli embeddings)](https://nlp.johnsnowlabs.com/2020/12/11/sbiobertresolve_rxcui_en.html)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 445
    },
    "id": "i4Jaj97KG2AT",
    "outputId": "789d7fdb-71c3-49ce-fe0a-303780b484cc"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warning::Spark Session already created, some configs may not take.\n",
      "Warning::Spark Session already created, some configs may not take.\n",
      "ner_wikiner_glove_840B_300 download started this may take some time.\n",
      "Approximate size to download 14.8 MB\n",
      "[OK!]\n",
      "sbiobertresolve_rxcui download started this may take some time.\n",
      "[OK!]\n",
      "setInputCols in ENTITY_57d31cc0027b expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: ['sentence_embeddings']\n",
      "sbiobert_base_cased_mli download started this may take some time.\n",
      "Approximate size to download 384.3 MB\n",
      "[OK!]\n",
      "glove_840B_300 download started this may take some time.\n",
      "Approximate size to download 2.3 GB\n",
      "[OK!]\n",
      "setInputCols in ENTITY_57d31cc0027b expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: ['sentence_embeddings']\n",
      "setInputCols in ENTITY_57d31cc0027b expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: ['sentence_embeddings']\n",
      "setInputCols in ENTITY_57d31cc0027b expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: ['sentence_embeddings']\n",
      "sentence_detector_dl download started this may take some time.\n",
      "Approximate size to download 354.6 KB\n",
      "[OK!]\n",
      "Warning::Spark Session already created, some configs may not take.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "  <div id=\"df-4443576d-8860-4b98-a970-21cb760477d0\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>entities_wikiner_glove_840B_300</th>\n",
       "      <th>sentence</th>\n",
       "      <th>word_embedding_glove</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>[]</td>\n",
       "      <td>He was seen by the endocrinology service and s...</td>\n",
       "      <td>[[0.02472599968314171, 0.273499995470047, 0.06...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-4443576d-8860-4b98-a970-21cb760477d0')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-4443576d-8860-4b98-a970-21cb760477d0 button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-4443576d-8860-4b98-a970-21cb760477d0');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "  entities_wikiner_glove_840B_300  \\\n",
       "0                              []   \n",
       "\n",
       "                                            sentence  \\\n",
       "0  He was seen by the endocrinology service and s...   \n",
       "\n",
       "                                word_embedding_glove  \n",
       "0  [[0.02472599968314171, 0.273499995470047, 0.06...  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nlp.load(\"med_ner.jsl.wip.clinical en.resolve.rxcui\").predict(\"He was seen by the endocrinology service and she was discharged on 50 mg of eltrombopag oral at night, 5 mg amlodipine with meals, and metformin 1000 mg two times a day\",output_level =  \"sentence\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "vifO7xR_LOhj"
   },
   "source": [
    "#### [Sentence Entity Resolver for RxNorm (sbiobert_base_cased_mli embeddings)](https://nlp.johnsnowlabs.com/2020/11/27/sbiobertresolve_rxnorm_en.html)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 535
    },
    "id": "m8cBuMRsLOhu",
    "outputId": "f242878a-1928-4906-8a83-383adf881baf"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warning::Spark Session already created, some configs may not take.\n",
      "Warning::Spark Session already created, some configs may not take.\n",
      "ner_wikiner_glove_840B_300 download started this may take some time.\n",
      "Approximate size to download 14.8 MB\n",
      "[OK!]\n",
      "sbiobertresolve_rxnorm download started this may take some time.\n",
      "[OK!]\n",
      "setInputCols in ENTITY_e8e8480527b5 expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: ['sentence_embeddings']\n",
      "sbiobert_base_cased_mli download started this may take some time.\n",
      "Approximate size to download 384.3 MB\n",
      "[OK!]\n",
      "glove_840B_300 download started this may take some time.\n",
      "Approximate size to download 2.3 GB\n",
      "[OK!]\n",
      "setInputCols in ENTITY_e8e8480527b5 expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: ['sentence_embeddings']\n",
      "setInputCols in ENTITY_e8e8480527b5 expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: ['sentence_embeddings']\n",
      "setInputCols in ENTITY_e8e8480527b5 expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: ['sentence_embeddings']\n",
      "sentence_detector_dl download started this may take some time.\n",
      "Approximate size to download 354.6 KB\n",
      "[OK!]\n",
      "Warning::Spark Session already created, some configs may not take.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "  <div id=\"df-5e031dee-d86d-47a6-b0ab-9d9d9da1f1bc\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>entities_wikiner_glove_840B_300</th>\n",
       "      <th>entities_wikiner_glove_840B_300_class</th>\n",
       "      <th>entities_wikiner_glove_840B_300_confidence</th>\n",
       "      <th>entities_wikiner_glove_840B_300_origin_chunk</th>\n",
       "      <th>entities_wikiner_glove_840B_300_origin_sentence</th>\n",
       "      <th>resolution_rxnorm_code</th>\n",
       "      <th>resolution_rxnorm_confidence</th>\n",
       "      <th>resolution_rxnorm_distance</th>\n",
       "      <th>resolution_rxnorm_k_codes</th>\n",
       "      <th>resolution_rxnorm_k_confidences</th>\n",
       "      <th>resolution_rxnorm_k_cos_distances</th>\n",
       "      <th>resolution_rxnorm_k_distances</th>\n",
       "      <th>resolution_rxnorm_k_resolution</th>\n",
       "      <th>resolution_rxnorm_origin_sentence</th>\n",
       "      <th>resolution_rxnorm_resolved_text</th>\n",
       "      <th>resolution_rxnorm_target_text</th>\n",
       "      <th>resolution_rxnorm_token</th>\n",
       "      <th>sentence</th>\n",
       "      <th>sentence_embedding_biobert</th>\n",
       "      <th>word_embedding_glove</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>[Braintree, non-ST, Guaiac, St, Margaret's Cen...</td>\n",
       "      <td>[LOC, MISC, MISC, LOC, ORG, ORG, ORG]</td>\n",
       "      <td>[0.8775, 0.873, 0.3519, 0.5045, 0.43828332, 0....</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>[607707, 1314253, 1373150, 583344, 1856515, 22...</td>\n",
       "      <td>[0.3374, 0.3438, 0.3529, 0.3344, 0.3399, 0.335...</td>\n",
       "      <td>[0.4892, 0.2549, 0.1804, 0.2870, 0.5064, 0.459...</td>\n",
       "      <td>[[607707, 215715, 352461], [1314253, 1363896, ...</td>\n",
       "      <td>[[0.3374, 0.3329, 0.3297], [0.3438, 0.3295, 0....</td>\n",
       "      <td>[[0.2393, 0.2524, 0.2623], [0.0650, 0.0885, 0....</td>\n",
       "      <td>[[0.4892, 0.5024, 0.5122], [0.2549, 0.2975, 0....</td>\n",
       "      <td>[[bionect, branchamin, baytet], [nonanal, berr...</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>[bionect, nonanal, guaiac, accu, levonorgestre...</td>\n",
       "      <td>[Braintree, non-ST, Guaiac, St, Margaret's Cen...</td>\n",
       "      <td>[Braintree, non-ST, Guaiac, St, Margaret's Cen...</td>\n",
       "      <td>This is an 82 - year-old male with a history o...</td>\n",
       "      <td>[[0.41123586893081665, 0.3981207609176636, -0....</td>\n",
       "      <td>[[-0.27410000562667847, 0.22980999946594238, 0...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-5e031dee-d86d-47a6-b0ab-9d9d9da1f1bc')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-5e031dee-d86d-47a6-b0ab-9d9d9da1f1bc button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-5e031dee-d86d-47a6-b0ab-9d9d9da1f1bc');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "                     entities_wikiner_glove_840B_300  \\\n",
       "0  [Braintree, non-ST, Guaiac, St, Margaret's Cen...   \n",
       "\n",
       "   entities_wikiner_glove_840B_300_class  \\\n",
       "0  [LOC, MISC, MISC, LOC, ORG, ORG, ORG]   \n",
       "\n",
       "          entities_wikiner_glove_840B_300_confidence  \\\n",
       "0  [0.8775, 0.873, 0.3519, 0.5045, 0.43828332, 0....   \n",
       "\n",
       "  entities_wikiner_glove_840B_300_origin_chunk  \\\n",
       "0                        [0, 1, 2, 3, 4, 5, 6]   \n",
       "\n",
       "  entities_wikiner_glove_840B_300_origin_sentence  \\\n",
       "0                           [0, 0, 0, 0, 0, 0, 0]   \n",
       "\n",
       "                              resolution_rxnorm_code  \\\n",
       "0  [607707, 1314253, 1373150, 583344, 1856515, 22...   \n",
       "\n",
       "                        resolution_rxnorm_confidence  \\\n",
       "0  [0.3374, 0.3438, 0.3529, 0.3344, 0.3399, 0.335...   \n",
       "\n",
       "                          resolution_rxnorm_distance  \\\n",
       "0  [0.4892, 0.2549, 0.1804, 0.2870, 0.5064, 0.459...   \n",
       "\n",
       "                           resolution_rxnorm_k_codes  \\\n",
       "0  [[607707, 215715, 352461], [1314253, 1363896, ...   \n",
       "\n",
       "                     resolution_rxnorm_k_confidences  \\\n",
       "0  [[0.3374, 0.3329, 0.3297], [0.3438, 0.3295, 0....   \n",
       "\n",
       "                   resolution_rxnorm_k_cos_distances  \\\n",
       "0  [[0.2393, 0.2524, 0.2623], [0.0650, 0.0885, 0....   \n",
       "\n",
       "                       resolution_rxnorm_k_distances  \\\n",
       "0  [[0.4892, 0.5024, 0.5122], [0.2549, 0.2975, 0....   \n",
       "\n",
       "                      resolution_rxnorm_k_resolution  \\\n",
       "0  [[bionect, branchamin, baytet], [nonanal, berr...   \n",
       "\n",
       "  resolution_rxnorm_origin_sentence  \\\n",
       "0             [0, 0, 0, 0, 0, 0, 0]   \n",
       "\n",
       "                     resolution_rxnorm_resolved_text  \\\n",
       "0  [bionect, nonanal, guaiac, accu, levonorgestre...   \n",
       "\n",
       "                       resolution_rxnorm_target_text  \\\n",
       "0  [Braintree, non-ST, Guaiac, St, Margaret's Cen...   \n",
       "\n",
       "                             resolution_rxnorm_token  \\\n",
       "0  [Braintree, non-ST, Guaiac, St, Margaret's Cen...   \n",
       "\n",
       "                                            sentence  \\\n",
       "0  This is an 82 - year-old male with a history o...   \n",
       "\n",
       "                          sentence_embedding_biobert  \\\n",
       "0  [[0.41123586893081665, 0.3981207609176636, -0....   \n",
       "\n",
       "                                word_embedding_glove  \n",
       "0  [[-0.27410000562667847, 0.22980999946594238, 0...  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nlp.load(\"med_ner.jsl.wip.clinical en.resolve.rxnorm\").predict(\"\"\"This is an 82 - year-old male with a history of prior tobacco use , hypertension , chronic renal insufficiency , COPD ,\n",
    "gastritis , and TIA who initially presented to Braintree with a non-ST elevation MI and Guaiac positive stools , transferred to St . Margaret\\'s Center for Women & Infants for cardiac\n",
    "catheterization with PTCA to mid LAD lesion complicated by hypotension and bradycardia requiring Atropine , IV fluids and transient dopamine possibly secondary to vagal reaction ,\n",
    "subsequently transferred to CCU for close monitoring , hemodynamically stable at the time of admission to the CCU .\"\"\",output_level =  \"sentence\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "c4y2ZMaeLOro"
   },
   "source": [
    "#### [Sentence Entity Resolver for Snomed Concepts, INT version (sbiobert_base_cased_mli embeddings)](https://nlp.johnsnowlabs.com/2020/11/27/sbiobertresolve_snomed_findings_int_en.html)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 535
    },
    "id": "XRmbCMNULOrq",
    "outputId": "3dee9730-64ed-4a26-ef0a-0906d72ffc78"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warning::Spark Session already created, some configs may not take.\n",
      "Warning::Spark Session already created, some configs may not take.\n",
      "ner_wikiner_glove_840B_300 download started this may take some time.\n",
      "Approximate size to download 14.8 MB\n",
      "[OK!]\n",
      "sbiobertresolve_snomed_findings_int download started this may take some time.\n",
      "[OK!]\n",
      "setInputCols in ENTITY_dcb03018cc1b expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: ['sentence_embeddings']\n",
      "sbiobert_base_cased_mli download started this may take some time.\n",
      "Approximate size to download 384.3 MB\n",
      "[OK!]\n",
      "glove_840B_300 download started this may take some time.\n",
      "Approximate size to download 2.3 GB\n",
      "[OK!]\n",
      "setInputCols in ENTITY_dcb03018cc1b expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: ['sentence_embeddings']\n",
      "setInputCols in ENTITY_dcb03018cc1b expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: ['sentence_embeddings']\n",
      "setInputCols in ENTITY_dcb03018cc1b expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: ['sentence_embeddings']\n",
      "sentence_detector_dl download started this may take some time.\n",
      "Approximate size to download 354.6 KB\n",
      "[OK!]\n",
      "Warning::Spark Session already created, some configs may not take.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "  <div id=\"df-bc5b7010-5c06-4e16-8ed3-174fa3580d5f\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>entities_wikiner_glove_840B_300</th>\n",
       "      <th>entities_wikiner_glove_840B_300_class</th>\n",
       "      <th>entities_wikiner_glove_840B_300_confidence</th>\n",
       "      <th>entities_wikiner_glove_840B_300_origin_chunk</th>\n",
       "      <th>entities_wikiner_glove_840B_300_origin_sentence</th>\n",
       "      <th>resolution_snomed_code</th>\n",
       "      <th>resolution_snomed_confidence</th>\n",
       "      <th>resolution_snomed_distance</th>\n",
       "      <th>resolution_snomed_k_codes</th>\n",
       "      <th>resolution_snomed_k_confidences</th>\n",
       "      <th>resolution_snomed_k_cos_distances</th>\n",
       "      <th>resolution_snomed_k_distances</th>\n",
       "      <th>resolution_snomed_k_resolution</th>\n",
       "      <th>resolution_snomed_origin_sentence</th>\n",
       "      <th>resolution_snomed_resolved_text</th>\n",
       "      <th>resolution_snomed_target_text</th>\n",
       "      <th>resolution_snomed_token</th>\n",
       "      <th>sentence</th>\n",
       "      <th>sentence_embedding_biobert</th>\n",
       "      <th>word_embedding_glove</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>[Braintree, non-ST, Guaiac, St, Margaret's Cen...</td>\n",
       "      <td>[LOC, MISC, MISC, LOC, ORG, ORG, ORG]</td>\n",
       "      <td>[0.8775, 0.873, 0.3519, 0.5045, 0.43828332, 0....</td>\n",
       "      <td>[0, 1, 2, 3, 4, 5, 6]</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>[70139002, 255199001, 770667002, 72670004, 289...</td>\n",
       "      <td>[0.3347, 0.3356, 0.3460, 0.3353, 0.3338, 0.333...</td>\n",
       "      <td>[0.5149, 0.2477, 0.3089, 0.2943, 0.4468, 0.432...</td>\n",
       "      <td>[[70139002, 49233005, 971211000000102], [25519...</td>\n",
       "      <td>[[0.3347, 0.3327, 0.3326], [0.3356, 0.3327, 0....</td>\n",
       "      <td>[[0.2652, 0.2713, 0.2717], [0.0613, 0.0658, 0....</td>\n",
       "      <td>[[0.5149, 0.5208, 0.5213], [0.2477, 0.2566, 0....</td>\n",
       "      <td>[[harara, dyspnea, reads bosnian], [benign tum...</td>\n",
       "      <td>[0, 0, 0, 0, 0, 0, 0]</td>\n",
       "      <td>[harara, benign tumor of pituitary and hypotha...</td>\n",
       "      <td>[Braintree, non-ST, Guaiac, St, Margaret's Cen...</td>\n",
       "      <td>[Braintree, non-ST, Guaiac, St, Margaret's Cen...</td>\n",
       "      <td>This is an 82 - year-old male with a history o...</td>\n",
       "      <td>[[0.41123586893081665, 0.3981207609176636, -0....</td>\n",
       "      <td>[[-0.27410000562667847, 0.22980999946594238, 0...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-bc5b7010-5c06-4e16-8ed3-174fa3580d5f')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-bc5b7010-5c06-4e16-8ed3-174fa3580d5f button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-bc5b7010-5c06-4e16-8ed3-174fa3580d5f');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "                     entities_wikiner_glove_840B_300  \\\n",
       "0  [Braintree, non-ST, Guaiac, St, Margaret's Cen...   \n",
       "\n",
       "   entities_wikiner_glove_840B_300_class  \\\n",
       "0  [LOC, MISC, MISC, LOC, ORG, ORG, ORG]   \n",
       "\n",
       "          entities_wikiner_glove_840B_300_confidence  \\\n",
       "0  [0.8775, 0.873, 0.3519, 0.5045, 0.43828332, 0....   \n",
       "\n",
       "  entities_wikiner_glove_840B_300_origin_chunk  \\\n",
       "0                        [0, 1, 2, 3, 4, 5, 6]   \n",
       "\n",
       "  entities_wikiner_glove_840B_300_origin_sentence  \\\n",
       "0                           [0, 0, 0, 0, 0, 0, 0]   \n",
       "\n",
       "                              resolution_snomed_code  \\\n",
       "0  [70139002, 255199001, 770667002, 72670004, 289...   \n",
       "\n",
       "                        resolution_snomed_confidence  \\\n",
       "0  [0.3347, 0.3356, 0.3460, 0.3353, 0.3338, 0.333...   \n",
       "\n",
       "                          resolution_snomed_distance  \\\n",
       "0  [0.5149, 0.2477, 0.3089, 0.2943, 0.4468, 0.432...   \n",
       "\n",
       "                           resolution_snomed_k_codes  \\\n",
       "0  [[70139002, 49233005, 971211000000102], [25519...   \n",
       "\n",
       "                     resolution_snomed_k_confidences  \\\n",
       "0  [[0.3347, 0.3327, 0.3326], [0.3356, 0.3327, 0....   \n",
       "\n",
       "                   resolution_snomed_k_cos_distances  \\\n",
       "0  [[0.2652, 0.2713, 0.2717], [0.0613, 0.0658, 0....   \n",
       "\n",
       "                       resolution_snomed_k_distances  \\\n",
       "0  [[0.5149, 0.5208, 0.5213], [0.2477, 0.2566, 0....   \n",
       "\n",
       "                      resolution_snomed_k_resolution  \\\n",
       "0  [[harara, dyspnea, reads bosnian], [benign tum...   \n",
       "\n",
       "  resolution_snomed_origin_sentence  \\\n",
       "0             [0, 0, 0, 0, 0, 0, 0]   \n",
       "\n",
       "                     resolution_snomed_resolved_text  \\\n",
       "0  [harara, benign tumor of pituitary and hypotha...   \n",
       "\n",
       "                       resolution_snomed_target_text  \\\n",
       "0  [Braintree, non-ST, Guaiac, St, Margaret's Cen...   \n",
       "\n",
       "                             resolution_snomed_token  \\\n",
       "0  [Braintree, non-ST, Guaiac, St, Margaret's Cen...   \n",
       "\n",
       "                                            sentence  \\\n",
       "0  This is an 82 - year-old male with a history o...   \n",
       "\n",
       "                          sentence_embedding_biobert  \\\n",
       "0  [[0.41123586893081665, 0.3981207609176636, -0....   \n",
       "\n",
       "                                word_embedding_glove  \n",
       "0  [[-0.27410000562667847, 0.22980999946594238, 0...  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nlp.load(\"med_ner.jsl.wip.clinical en.resolve.snomed.findings_int\").predict(\"\"\"This is an 82 - year-old male with a history of prior tobacco use , hypertension , chronic renal insufficiency , COPD ,\n",
    "gastritis , and TIA who initially presented to Braintree with a non-ST elevation MI and Guaiac positive stools , transferred to St . Margaret\\'s Center for Women & Infants for cardiac\n",
    "catheterization with PTCA to mid LAD lesion complicated by hypotension and bradycardia requiring Atropine , IV fluids and transient dopamine possibly secondary to vagal reaction ,\n",
    "subsequently transferred to CCU for close monitoring , hemodynamically stable at the time of admission to the CCU .\"\"\",output_level =  \"sentence\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "f_mvF_EQj86x"
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "colab": {
   "provenance": []
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
